package edu.imac.angryfood.utils;

import java.util.ArrayList;

public class Account {
	private String name;
	
	private String password;
	private String last_level;
	private int max_score;
	private ArrayList<Integer> score_by_level = new ArrayList<Integer>(); 
	
	/**
	 * to load the accounts
	 * @param name
	 * @param password
	 * @param lastlevel
	 * @param max_score
	 * @param score_by_level
	 */
	public Account(String name,String password,String lastlevel, int max_score,ArrayList<Integer> score_by_level){
		this.setName(name);
		
		this.setPassword(password);
		this.setLast_level(lastlevel);
		this.setMax_score(max_score);
		this.score_by_level=score_by_level;
		
	}
	
	/**
	 * to load the accounts
	 * @param name
	 * @param password
	 * @param last_level
	 * @param max_score
	 */
	public Account(String name,String password,String last_level, int max_score){
		this.setName(name);
		
		this.setPassword(password);
		this.setLast_level(last_level);
		this.setMax_score(max_score);
		
	}
	/**
	 * to create a new account
	 * @param name
	 * @param password
	 */
	public Account(String name,String password){
		this.setName(name);
		
		this.setPassword(password);
		this.setLast_level("");
		this.setMax_score(0);
		
	}

	/**
	 * to compute the scores
	 */
	public void calculateMaxScore(){
		int cpt =0;
		for(int i=0;i<this.getScore_by_level().size();i++){
			cpt=cpt+ this.getScore_by_level().get(i);
		}
		this.setMax_score(cpt);
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPassword() {
		return password;
	}

	public void setLast_level(String last_level) {
		this.last_level = last_level;
	}

	public String getLast_level() {
		return last_level;
	}

	public void setMax_score(int max_score) {
		this.max_score = max_score;
	}

	public int getMax_score() {
		return max_score;
	}
	
	public String toString(){
		String s="";
		s=s+"nom : "+this.getName()+" password : "+this.getPassword()+ " dernier niveau : "+this.getLast_level()+ " score max : "+this.getMax_score();
		
		return s;
	}
	public void setScore_by_level(ArrayList<Integer> score_by_level) {
		this.score_by_level = score_by_level;
	}
	public ArrayList<Integer> getScore_by_level() {
		return score_by_level;
	}
	

}
